package com.example.administrator.matriximage.viewpack.group;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;

public class InterRecylerView  extends RecyclerView {
    public InterRecylerView(Context context) {
        super(context);
    }

    public InterRecylerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public InterRecylerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }


    boolean inter=true;

    public boolean isInter() {
        return inter;
    }

    public void setInter(boolean inter) {
        this.inter = inter;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e)
    {

        return inter;
    }

   final String tag=getClass().getName();
    ScaleGestureDetector.SimpleOnScaleGestureListener simpleOnScaleGestureListener=
            new ScaleGestureDetector.SimpleOnScaleGestureListener()
            {
                @Override
                public boolean onScale(ScaleGestureDetector detector) {
                    android.util.Log.e(tag,detector.getScaleFactor()+"");
                    inter =  detector.getScaleFactor()>1;
                    return super.onScale(detector);
                }

                @Override
                public boolean onScaleBegin(ScaleGestureDetector detector) {

                    return super.onScaleBegin(detector);
                }

                @Override
                public void onScaleEnd(ScaleGestureDetector detector) {

                    super.onScaleEnd(detector);
                }
            };
    ScaleGestureDetector scaleGestureDetector=new ScaleGestureDetector(getContext(),simpleOnScaleGestureListener);


    @Override
    public boolean onTouchEvent(MotionEvent e) {

        scaleGestureDetector.onTouchEvent(e);

        return super.onTouchEvent(e);
    }



}
